﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewPengguna.aspx.cs" Inherits="SIAKAD.ViewPengguna" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>SIAKAD - PENGGUNA</title>

    <!-- normalize.css -->
    <link href="Content/normalize.css" rel="stylesheet" />

    <!-- Bootstrap -->
    <link href="Content/bootstrap.min.css" rel="stylesheet" />

    <!-- SIAKAD style -->
    <link href="Content/Css/Siakad.css" rel="stylesheet" />

    <!-- jQuery -->
    <script src="Scripts/jquery-2.1.0.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>

    <!-- SIAKAD script -->
    <script src="Scripts/Js/Siakad.js"></script>
    <script src="Scripts/Js/ViewPengguna.js"></script>

    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <form id="frmViewPengguna" runat="server">
        <asp:ScriptManager ID="scriptManager" runat="server" />

        <!-- navbar -->
        <div class="navbar navbar-default navbar-fixed-top" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">SIAKAD</a>
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="ViewPengguna.aspx">Pengguna</a></li>
                        <li><a href="#">Role</a></li>
                    </ul>
                </div>
            </div>
        </div>

        <!-- body -->
        <div class="container">
            <div class="page-header">
                <h1>Pengguna</h1>
            </div>

            <div class="row">
                <div class="container">
                    <div class="pull-right">
                        <div id="searchBox" class="form-inline">
                            <asp:TextBox ID="txtSearch" runat="server" CssClass="form-control" placeholder="username" />
                            <asp:Button ID="btSearch" Text="Search" CssClass="btn" runat="server" OnClick="btSearch_Click" />
                        </div>
                    </div>
                </div>
            </div>

            <div style="margin-bottom:10px"></div>

            <asp:UpdatePanel ID="upCrudGrid" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="gvPengguna" runat="server"
                        CellSpacing="-1" GridLines="None"
                        CssClass="table table-hover" AutoGenerateColumns="false"
                        OnRowCommand="gvPengguna_RowCommand" DataKeyNames="id_user"
                        AllowPaging="true" OnPageIndexChanging="gvPengguna_PageIndexChanging" PageSize="10">
                        <Columns>
                            <asp:TemplateField HeaderStyle-Width="70px" HeaderText="NO"> 
                                <ItemTemplate> 
                                    <%# Container.DataItemIndex + 1 %>. 
                                </ItemTemplate> 
                                <ItemStyle HorizontalAlign="Right" /> 
                            </asp:TemplateField>
                            <asp:BoundField DataField="username" HeaderText="USERNAME" HeaderStyle-Width="250px" />
                            <asp:BoundField DataField="nama_role" HeaderText="ROLE" />
                            <asp:ButtonField CommandName="updateRecord" Text="<span class='glyphicon glyphicon-edit'></span> EDIT ROLE" ButtonType="Link" HeaderStyle-Width="140px" />
                            <asp:ButtonField CommandName="deleteRecord" Text="<span class='glyphicon glyphicon-remove'></span> DELETE USER" ButtonType="Link" HeaderStyle-Width="170px" />
                        </Columns>
                        <PagerSettings FirstPageText="First" LastPageText="Last" 
                            Mode="NumericFirstLast" PageButtonCount="5" NextPageText="Next" PreviousPageText="Prev" position="Bottom" />
                        <PagerStyle HorizontalAlign = "Center" CssClass = "GridPager" />
                    </asp:GridView>
                    <div style="text-align:center; margin:20px">
                        <asp:Button ID="btAdd" runat="server" Text="Tambah Pengguna" CssClass="btn btn-default" OnClick="btAdd_Click" />
                    </div>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btAdd" EventName="Click" />
                    <%--<asp:AsyncPostBackTrigger ControlID="gvPengguna" EventName="PageIndexChanging" />--%>
                </Triggers>
            </asp:UpdatePanel>
        </div>

        <div id="addModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title"><span class="glyphicon glyphicon-plus"></span> Tambah Pengguna</h4>
                    </div>
                    <asp:UpdatePanel ID="upAdd" runat="server">
                        <ContentTemplate>
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="ddlAddMahasiswaDosen">Tipe Pengguna</label>
                                    <asp:DropDownList ID="ddlAddMahasiswaDosen" runat="server" CssClass="form-control" OnSelectedIndexChanged="ddlAddMahasiswaDosen_SelectedIndexChanged" AutoPostBack="true" />
                                </div>
                                <div class="form-group">
                                    <label for="ddlAddRole">Role</label>
                                    <asp:DropDownList ID="ddlAddRole" runat="server" CssClass="form-control" />
                                </div>
                                <div class="form-group">
                                    <label for="txtAddNIPNRP"><asp:Literal ID="ltNIPNRP" runat="server" /></label>
                                    <asp:TextBox ID="txtAddNIPNRP" runat="server" CssClass="form-control" />
                                </div>
                                <div class="form-group">
                                    <label for="txtAddNama"><asp:Literal ID="ltNama" runat="server" /></label>
                                    <asp:TextBox ID="txtAddNama" runat="server" CssClass="form-control" />
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
                                <asp:Button ID="btAddPengguna" runat="server" Text="Tambah" CssClass="btn btn-primary" OnClick="btAddPengguna_Click" />
                            </div>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="ddlAddMahasiswaDosen" EventName="SelectedIndexChanged" />
                            <asp:AsyncPostBackTrigger ControlID="btAddPengguna" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </div>
        </div>

        <div id="editModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title"><span class="glyphicon glyphicon-pencil"></span> Ubah Role Pengguna</h4>
                    </div>
                    <asp:UpdatePanel ID="upEdit" runat="server">
                        <ContentTemplate>
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="ddlEditRole">Role</label>
                                    <asp:DropDownList ID="ddlEditRole" runat="server" CssClass="form-control" />
                                    <asp:HiddenField ID="hfUpdateID" runat="server" />
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
                                <asp:Button ID="btEditRole" runat="server" Text="Ubah" CssClass="btn btn-primary" OnClick="btEditRole_Click" />
                            </div>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="gvPengguna" EventName="RowCommand" />
                            <asp:AsyncPostBackTrigger ControlID="btEditRole" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </div>
        </div>

        <div id="deleteModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title"><span class="glyphicon glyphicon-trash"></span> Hapus Pengguna</h4>
                    </div>
                    <asp:UpdatePanel ID="upDelete" runat="server">
                        <ContentTemplate>
                            <div class="modal-body">
                                <p>Anda yakin ingin menghapus pengguna ini?</p><asp:HiddenField ID="hfDeleteID" runat="server" />
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
                                <asp:Button ID="btDeletePengguna" runat="server" Text="Hapus" CssClass="btn btn-primary" OnClick="btDeletePengguna_Click" />
                            </div>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btDeletePengguna" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </div>
        </div>

        <!-- footer start -->
        <div id="footer">
            <div class="container">
                <p class="text-muted">&copy; <%: DateTime.Now.Year.ToString() %> Rezki Wulan Permata Sari</p>
            </div>
        </div>
    </form>
</body>
</html>
